package com.wander.provider.service.impl;

import com.alibaba.dubbo.rpc.protocol.rest.support.ContentType;
import com.wander.api.service.UserRestService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

/**
 * @author Wander.Zeng
 * @create 2018-02-11 17:47
 * @desc UserRestServiceImpl
 */
@Path("demo")
@Produces({ContentType.APPLICATION_JSON_UTF_8})
@Consumes({MediaType.APPLICATION_JSON})
public class UserRestServiceImpl implements UserRestService {

    private Logger logger = LoggerFactory.getLogger(UserRestServiceImpl.class);

    @GET
    @Path("/{loginName}/{password}/{id : \\d+}")
    @Override
    public String login(@PathParam("loginName") String loginName, @PathParam("password") String password, @PathParam("id") Long id) {
        logger.info("用户登录：[username:{}, password:{}]", loginName, password);
        if (null != loginName && null != password) {
            logger.info("用户校验通过。[username:{}]", loginName);
            return "success " + id;
        }
        logger.info("用户校验失败！[username:{}]", loginName);
        return "false";
    }

}
